package com.hxk.ioText.byteIo.handleIo;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

public class BufferIo {

	public static void main(String[] args) {
		BufferedInputStream bis = null;
		BufferedOutputStream bos = null;
		try {
			bis = new BufferedInputStream(new FileInputStream("d:/textio.txt"));
			bos = new BufferedOutputStream(new FileOutputStream("d:/textio1.txt"));
			byte[] buf = new byte[1024];
			int len = bis.read(buf);
			while(len != -1) {
				bos.write(buf, 0, len);
				len = bis.read(buf);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}finally {
			try {
				if(bis != null) {
					bis.close();
				}
			} catch (IOException e) {
				e.printStackTrace();
			}
			try {
				if(bos != null) {
					bos.close();
				}
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}

}
